package zhoug.demo.chart2;

import android.os.Bundle;
import android.widget.Button;

import zhoug.chart.charts.MPBarChart;
import zhoug.chart.charts.MPCombinedChart;
import zhoug.chart.charts.MPHorizontalBarChart;
import zhoug.chart.charts.MPLineChart;
import zhoug.chart.charts.MPPieChart;
import zhoug.chart.charts.MPRadarChart;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
 * 占位图测试
 *
 * @Author: zhoug
 * @Date: 2024-01-30
 * @Description:
 */
public class PlaceHolderTestActivity extends AppCompatActivity {

    private Button mBtnEmpty;
    private Button mBtnError;
    private Button mBtnReset;
    private MPBarChart mBarChart;
    private MPCombinedChart mCombinedChart;
    private MPHorizontalBarChart mHorizontalBarChart;
    private MPLineChart mLineChart;
    private MPPieChart mPieChart;
    private MPRadarChart mRadarChart;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_place_holder_test);
        findViews();

        mBtnEmpty.setOnClickListener(v -> {
            mBarChart.empty();
            mCombinedChart.empty();
            mHorizontalBarChart.empty();
            mLineChart.empty();
            mPieChart.empty();
            mRadarChart.empty();
        });
        mBtnError.setOnClickListener(v -> {
            mBarChart.error();
            mCombinedChart.error();
            mHorizontalBarChart.error();
            mLineChart.error();
            mPieChart.error();
            mRadarChart.error();
        });
        mBtnReset.setOnClickListener(v -> {
            mBarChart.resetPlaceholder();
            mCombinedChart.resetPlaceholder();
            mHorizontalBarChart.resetPlaceholder();
            mLineChart.resetPlaceholder();
            mPieChart.resetPlaceholder();
            mRadarChart.resetPlaceholder();
        });

    }


    private void findViews() {
        mBtnEmpty = findViewById(R.id.btn_empty);
        mBtnError = findViewById(R.id.btn_error);
        mBtnReset = findViewById(R.id.btn_reset);
        mBarChart = findViewById(R.id.barChart);
        mCombinedChart = findViewById(R.id.combinedChart);
        mHorizontalBarChart = findViewById(R.id.horizontalBarChart);
        mLineChart = findViewById(R.id.lineChart);
        mPieChart = findViewById(R.id.pieChart);
        mRadarChart = findViewById(R.id.radarChart);
    }
}
